 var mongoose = require('mongoose'); //引用mongoose模块
 var dbconfig = require('./config/default')
 var db = mongoose.connection;
 mongoose.connect(dbconfig.mongodb); //数据库连接
 db.on('error', console.error.bind(console, '连接错误:'));
 var PersonSchema = new mongoose.Schema({
     name: String //定义一个属性name，类型为String
 });
 //为Schema模型追加speak方法
 PersonSchema.methods.printBrief = function() {
     console.log('￥');
 }
 PersonSchema.statics.showCount = function() {
     this.count({}, (err, count) => {
         console.log('---printCount()-----------------------------')
         if (err) {
             console.log(err);
         } else {
             console.log('phone count=' + count);
         }
     });
 }
 var PersonModel = db.model('Person', PersonSchema);
 var personEntity = new PersonModel({ name: 'Krouky' });
 PersonModel.showCount();
 var personEntity = new PersonModel({ name: 'Krouky' });
 personEntity.printBrief(); //我的名字叫Krouky
 //personEntity.save(); //执行完成后，数据库就有该数据了
 PersonModel.find(function(err, persons) {
     persons.forEach(function(va) {
         console.log(va)
     })
 });